/* 
 * Copyright 2014 Josef Hertl.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package caetus.modelChecking.variable;

/**
 * Represents a variable in the model-checking.
 *
 * @author Josef Hertl
 */
public abstract class ModelVariable implements Comparable<ModelVariable> {

    /**
     * Contains the whole string, even in the composed variables.
     */
    protected String name;

    /**
     * @return A string representation of the variable type.
     */
    public abstract String getVariableType();

    /**
     * @return Name of the variable - it works even for the composed types. i.e.
     * for composed variables it may return {SK}_EK or Na'.Nb ...
     */
    public String getVariableName() {
        return name;
    }

    @Override
    public int compareTo(ModelVariable o) { //Only for composed types, the basis overrides this.
        if (o instanceof ModelBaseVariable) {
            return 1;
        } else {
            if (getVariableType().equals(o.getVariableType())) {
                return name.compareTo(o.getVariableName());
            } else {
                return getVariableType().compareTo(o.getVariableType());
            }
        }
    }

    @Override
    public String toString() {
        return name;
    }
}
